<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body style="padding:15px;">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题名称" class="layui-input" value="{$vo.title}">
        </div>
    </div>

    <div class="layui-form-item"  >
        <label class="layui-form-label">天数</label>
        <div class="layui-input-block">
            <input type="number" name="days" lay-verify="title" autocomplete="off" placeholder="请输入有效期" class="layui-input" value="{$vo.days}">
        </div>
    </div>

    <div class="layui-form-item"  >
        <label class="layui-form-label">价格(元)</label>
        <div class="layui-input-block">
            <input type="number" name="price" lay-verify="title" autocomplete="off" placeholder="请输入价格" class="layui-input" value="{$vo.price}">
        </div>
    </div>

    <div class="layui-form-item"  >
        <label class="layui-form-label">充值赠送余额(元)</label>
        <div class="layui-input-block">
            满<input type="number" style="width:124px" name="song_money" lay-verify="title" autocomplete="off" placeholder="无优惠请输入0" class="layui-input" value="{$vo.song_money}">
            赠送<input type="number" style="width:124px" name="song_money2" lay-verify="title" autocomplete="off" placeholder="无优惠请输入0" class="layui-input" value="{$vo.song_money2}">
        </div>
    </div>
    <div class="layui-form-item"  >
        <label class="layui-form-label">店铺入驻折扣(0-10)</label>
        <div class="layui-input-block">
            <input type="number" name="shop_discount" lay-verify="title" autocomplete="off" placeholder="无优惠请输入0" class="layui-input" value="{$vo.shop_discount}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" >发帖优惠选项</label>
        <div class="layui-input-block">
            <select name="type" lay-verify="required" lay-filter="test">
                <option value="1" <if condition="$vo['is_fee'] == '1'">selected</if> >每条帖子优惠价格</option>
                <option value="2" <if condition="$vo['is_num'] == '1'">selected</if> >免费发帖条数</option>
            </select>
        </div>
    </div>
    <if condition="$vo['title'] neq ''">
        <div class="layui-form-item" id="you1" <if condition="$vo['is_fee'] == '1'"><else/> style='display:none'</if>>
            <label class="layui-form-label">发帖优惠价格（元/条）</label>
            <div class="layui-input-block">
                <input type="number" name="tie_fee" lay-verify="title" autocomplete="off" placeholder="请输入优惠价格" class="layui-input" value="{$vo.tie_fee}">
                当前收费{$wechat['tongcheng_fee']}元/条
            </div>
        </div>
        <div class="layui-form-item" id="you2" <if condition="$vo['is_num'] == '1'"><else/> style='display:none'</if>>
            <label class="layui-form-label">发帖免费条数(免费N条)</label>
            <div class="layui-input-block">
                <input type="number" name="tie_num" lay-verify="title" autocomplete="off" placeholder="请输入免费条数" class="layui-input" value="{$vo.tie_num}">
            </div>
        </div>
    <else/>
        <div class="layui-form-item" id="you1" >
            <label class="layui-form-label">发帖优惠价格（元/条）</label>
            <div class="layui-input-block">
                <input type="number" name="tie_fee" lay-verify="title" autocomplete="off" placeholder="请输入优惠价格" class="layui-input" value="{$vo.tie_fee}">
                当前收费{$wechat['tongcheng_fee']}元/条
            </div>
        </div>
        <div class="layui-form-item" id="you2" style='display:none'>
            <label class="layui-form-label">发帖免费条数(免费N条)</label>
            <div class="layui-input-block">
                <input type="number" name="tie_num" lay-verify="title" autocomplete="off" placeholder="请输入免费条数" class="layui-input" value="{$vo.tie_num}">
            </div>
        </div>
    </if>

    <!--<div class="layui-form-item">
        <label class="layui-form-label">同城卡图片</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <button type="button" class="layui-btn layui-btn-danger" id="test1"><i class="layui-icon"></i>上传图片</button>
                &lt;!&ndash;<spaan style="color: #9d9d9d;">建议尺寸:900×350</spaan>&ndash;&gt;
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="demo1" src="{$vo.pic}" style="width: 200px;<if condition="!$vo['pic']">display: none;</if>">
                    <p id="demoText"></p>
                </div>
            </div>
            <input type="hidden" id="imgurl" name="imgurl" value="{$vo.pic}">
        </div>
    </div>
-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="*">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="__PUBLIC__/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script>

</script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form','upload','element','laypage','layer'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,$ = layui.jquery
                ,upload = layui.upload;

        form.on('select(test)', function(data){
            var val = data.value;
            if(val == 1){
                $('#you1').css('display','');
                $('#you2').css('display','none');
            }
            if(val ==2){
                $('#you1').css('display','none');
                $('#you2').css('display','');
            }
        });

        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '{:U("Home/Public/upload")}'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result).show(); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.err_code > 0){
                    return layer.msg('上传失败');
                }else{
                    $("#imgurl").val("https://www.58zltc.com/Uploads/"+res.file_name);
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        //监听提交
        form.on('submit(*)', function(data){
            $.post('#', data.field, function(e) {
                layer.alert(e.info,function(index){
                    parent.location.reload();
                });
            });
            return false;
        });


    });
</script>

</body>
</html>